fix(account-mapping): repair benchmark failures for EVM accounts#89
Merged
Conversation
Three benchmarks failed when running on the Hetzner reference node: 1. map_account / unmap_account → NativeAccountCannotBeMapped Root cause: whitelisted_caller() produces a Substrate AccountId32 whose bytes[20..32] are not [0u8; 12] (EVM_ACCOUNT_MARKER), so AccountIdToEvmAddress::convert returns None. Fix: new helper evm_account<T>() builds an AccountId with a deterministic H160 in bytes[0..20] and [0u8;12] in bytes[20..32]. 2. dispatch_as_private_link → InvalidProof Root cause: PrivateLinkZkAdapter calls the real pallet-zk-verifier Groth16 verifier; the mock proof [0x01, 0x00, ...] fails. Fix: add a #[cfg(feature = "runtime-benchmarks")] bypass in PrivateLinkZkAdapter::verify that accepts any non-empty proof. The actual ZK pairing cost is benchmarked separately via pallet_zk_verifier::verify_proof. Changes: - frame/account-mapping/src/benchmarking.rs · add evm_account<T>() helper · #[benchmarks] where clause: + T::AccountId: From<[u8; 32]> · map_account, unmap_account: use evm_account::<T>() as caller - template/runtime/src/lib.rs · PrivateLinkZkAdapter::verify: short-circuit under runtime-benchmarks
… for improved compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three benchmarks failed when running on the Hetzner reference node:
map_account / unmap_account → NativeAccountCannotBeMapped Root cause: whitelisted_caller() produces a Substrate AccountId32 whose bytes[20..32] are not [0u8; 12] (EVM_ACCOUNT_MARKER), so AccountIdToEvmAddress::convert returns None. Fix: new helper evm_account() builds an AccountId with a deterministic H160 in bytes[0..20] and [0u8;12] in bytes[20..32].
dispatch_as_private_link → InvalidProof Root cause: PrivateLinkZkAdapter calls the real pallet-zk-verifier Groth16 verifier; the mock proof [0x01, 0x00, ...] fails. Fix: add a #[cfg(feature = "runtime-benchmarks")] bypass in PrivateLinkZkAdapter::verify that accepts any non-empty proof. The actual ZK pairing cost is benchmarked separately via pallet_zk_verifier::verify_proof.
Changes:
· #[benchmarks] where clause: + T::AccountId: From<[u8; 32]>
· map_account, unmap_account: use evm_account::() as caller